/*******************************************************************************
 * The MOSES project, model based software engineering of networked embedded systems.
 * 
 * Copyright (C) 2010-2013, University of Applied Sciences Wildau,
 * Telematics Research Group, http://www.tm.th-wildau.de/research-group
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses>.
 * 
 * Contributors:
 *     University of Applied Sciences Wildau - initial API and implementation
 * 
 * If you are interested in a commercial license please contact us via 
 * e-mail: ralf.vandenhouten@th-wildau.de.
 ******************************************************************************/
package de.thwildau.tm.moses.asn1.util;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.naming.QualifiedName;

import com.google.inject.ImplementedBy;

import de.thwildau.tm.moses.asn1.asn1.Assignment;
import de.thwildau.tm.moses.asn1.asn1.ModuleDefinition;

/**
 * Common interface for name conversions.
 *
 * @author Thomas Kistel
 * @version $Revision: 763 $
 */
@ImplementedBy(JavaNamesConverter.class)
public interface NamesConverter {

    /**
     * Returns the package name of the given resource. Therefore the resource must be a platform resource. This
     * method returns <code>null</code>, if the given resource is not a platform resource or if the resource is in
     * the default package (no package).
     * 
     * @param resource the resource
     * @return the package name of the resource or <code>null</code>
     * @see URI#isPlatformResource()
     */
    public QualifiedName getPackageName(Resource resource);

    public <T extends Assignment> EObjectResourceDescription<T> getResourceDescription(T element);
    
    /**
     * Returns the ResourceDescription of the given element. The className and the fileName of the {@link EObjectResourceDescription}
     * is derived from the given <code>name</code> attribute.
     * 
     * @param element the element of a ASN.1 file
     * @param name the name of the className for the given element
     * @return the resource description
     * @see EObjectResourceDescription#getClassName()
     */
    public <T extends EObject> EObjectResourceDescription<T> getResourceDescription(T element, String name);

    /**
     * Converts the given ModuleDefinition into a package name. Therefore the module-reference of the the ModuleIdentifier
     * is converted into a package name. 
     * 
     * @param moduleDefinition the ModuleDefinition
     * @return the converted package name
     */
    public QualifiedName toPackageName(ModuleDefinition moduleDefinition);
    
    /**
     * Return the class name of the given reference as a QualifiedName. The given ASN.1
     * reference may contain upper case letters that are converted to lower case according
     * to standard Java naming conversion.
     * 
     * @param reference the ASN.1 reference
     * @return the Qualified name of the class name (may without package name)
     */
    public QualifiedName toClassName(String reference);

    /**
     * Converts the given reference into a valid class field name of the target language. E.g. a reference in ASN.1 could be
     * "reference-id". This reference is converted into "referenceId" for the Java language. 
     *  
     * @param reference the ASN.1 reference
     * @return die converted reference name for class fields
     */
    public String toFieldName(String reference);

    /**
     * Converts the given reference into a valid Enum field name of the target language. E.g. a reference in ASN.1 could be
     * "reference-id". This reference is converted into "REFERENCE_ID" for the Java language. 
     *  
     * @param reference the ASN.1 reference
     * @return die converted reference name for Enum fields
     */
    public String toEnumField(String reference);

    
}
